package com.wbt.huawei.c20220717;

import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

public class HJ28 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int num = sc.nextInt();
            List<Integer> nums = new ArrayList<>();
            for (int i = 0 ; i < num; i++){
                nums.add(sc.nextInt());
            }

            int count = find(nums);
            System.out.println(count);

        }
    }

    // 递归处理
    public static Integer find(List<Integer> ints){
        int leng = ints.size();
        if(leng == 2){
            if(isPrime(ints.get(0) + ints.get(1))){
                return 1;
            }else {
                return 0;
            }
        }
        List<Integer> reList = new ArrayList();
        for (int i=0; i < leng -1 ; i++) {
            for (int j = i + 1;j<leng;j++) {
                int tag = 0;
                if(isPrime(ints.get(i) + ints.get(j))){
                    tag = 1;
                }
                List<Integer> collect = ints.stream().collect(Collectors.toList());
                collect.removeAll(Arrays.asList(ints.get(i),ints.get(j)));

                tag += find(collect);
                reList.add(tag);
            }
        }
        return Collections.max(reList);
    }

    // 素数判断
    public static boolean isPrime(Integer num){
        boolean tag = true;
        for (int i = 2; i * i <= num; i++){
            if(num % i == 0){
                tag = false;
                break;
            }
        }
        return tag;
    }

}
